load("@rules_rust//rust:defs.bzl", "rust_doc_test", "rust_library", "rust_test", "rust_test_suite")
load("//bazel:fuzz_testing.bzl", "DEFAULT_RUSTC_FLAGS_FOR_FUZZING")

package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
    # Keep sorted.
    "//rs/crypto/interfaces/sig_verification",
    "//rs/crypto/standalone-sig-verifier",
    "//rs/crypto/utils/threshold_sig_der",
    "//rs/types/types",
    "//rs/validator",
    "@crate_index//:base64",
    "@crate_index//:hex",
    "@crate_index//:ic-cdk",
    "@crate_index//:time",
]

DEV_DEPENDENCIES = [
    # Keep sorted.
    "//rs/canister_client/sender",
    "//rs/certification/test-utils",
    "//rs/crypto/test_utils/canister_sigs",
    "//rs/crypto/test_utils/reproducible_rng",
    "//rs/crypto/test_utils/root_of_trust",
    "//rs/crypto/tree_hash",
    "//rs/limits",
    "//rs/registry/helpers",
    "//rs/validator/http_request_test_utils",
    "@crate_index//:assert_matches",
    "@crate_index//:rand",
    "@crate_index//:strum",
]

MACRO_DEPENDENCIES = []

DEV_MACRO_DEPENDENCIES = []

ALIASES = {}

rust_library(
    name = "ingress_message",
    srcs = glob(["src/**/*.rs"]),
    aliases = ALIASES,
    crate_name = "ic_validator_ingress_message",
    proc_macro_deps = MACRO_DEPENDENCIES,
    rustc_flags = select({
        "//bazel:fuzzing_code_enabled": DEFAULT_RUSTC_FLAGS_FOR_FUZZING,
        "//conditions:default": [],
    }),
    deps = DEPENDENCIES,
)

rust_test(
    name = "ingress_message_test",
    crate = ":ingress_message",
    proc_macro_deps = DEV_MACRO_DEPENDENCIES,
    deps = DEV_DEPENDENCIES,
)

rust_test_suite(
    name = "ingress_message_integration",
    srcs = glob(
        ["tests/*.rs"],
    ),
    proc_macro_deps = MACRO_DEPENDENCIES + DEV_MACRO_DEPENDENCIES,
    deps = [":ingress_message"] + DEPENDENCIES + DEV_DEPENDENCIES,
)

rust_doc_test(
    name = "ingress_message_doc_test",
    crate = ":ingress_message",
)
